home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / genial / ui / xscale.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-14  |  1.5 KB  |  55 lines

  1. /*
  2.  * xscale.c -- Xlib scale labeller
  3.  *
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <X11/Xlib.h>
  8. #include "scale.h"
  9.  
  10. /*
  11.  * xlabelgraph() places a graph label structure in an X Window.
  12.  * xid is the window, lvec and len are the graph_lab vector and its length.
  13.  * (x,y) is the starting point for the labels, orientation is either VERTICAL
  14.  * or HORIZONTAL (as defined in scale.h) and direction is either +1 or -1.
  15.  *
  16.  */
  17.  
  18. xlabelgraph(display, xid, gc, lvec, len, x, y, width, height, orientation, direction)
  19.     Display  *display;
  20.     XID       xid;
  21.     GC        gc;
  22.     struct graph_lab *lvec;
  23.     int       len, x, y, width, height, orientation, direction;
  24. {
  25.     XGCValues gcval;
  26.     int       i;
  27.     XPoint    loc, org;
  28.  
  29.     loc.x = x;
  30.     loc.y = y;
  31.     org.x = loc.x - width;
  32.     org.y = loc.y - height;
  33.     for (i = 0; i < len; i++) {
  34.     if (orientation == HORIZONTAL) {
  35.         loc.x = x + lvec[i].p_off * direction;
  36.         loc.y = y + 15;
  37.         org.x = loc.x;
  38.     } else {
  39.         loc.y = y + lvec[i].p_off * direction;
  40.         org.y = loc.y;
  41.     }
  42.     gcval.line_style = LineOnOffDash;
  43.     XChangeGC(display, gc, GCLineStyle, &gcval);
  44.     XDrawLine(display, xid, gc, org.x, org.y, loc.x, loc.y);
  45.     if (orientation == HORIZONTAL)
  46.         XDrawImageString(display, xid, gc, loc.x, loc.y,
  47.                  lvec[i].lab, strlen(lvec[i].lab));
  48.     else
  49.         XDrawImageString(display, xid, gc, loc.x + 2, loc.y,
  50.                  lvec[i].lab, strlen(lvec[i].lab));
  51.     }
  52.     gcval.line_style = 0;
  53.     XChangeGC(display, gc, GCLineStyle, &gcval);
  54. }
  55.